package tx.bj12320.model;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;

import javax.validation.constraints.*;
import org.hibernate.validator.constraints.*;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import tx.bj12320.model.*;
import tx.bj12320.dao.*;
import tx.bj12320.service.*;
import tx.bj12320.vo.query.*;


@Entity
@Table(name = "BJ12320_RESOURCE")
public class Resource extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;

	//alias
	public static final String TABLE_ALIAS = "Resource";
	public static final String ALIAS_RESOURCE_ID = "resourceId";
	public static final String ALIAS_USER_INFO_ID = "userInfoId";
	public static final String ALIAS_RESOURCE_NAME = "resourceName";
	public static final String ALIAS_RESOURCE_TYPE = "resourceType";
	public static final String ALIAS_RESOURCE_SIZE = "resourceSize";
	public static final String ALIAS_RESOURCE_FILE = "resourceFile";
	public static final String ALIAS_RESOURCE_ISSUE_DATE = "resourceIssueDate";

	//date formats
	public static final String FORMAT_RESOURCE_ISSUE_DATE = DATE_FORMAT;


	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * resourceId       db_column: RESOURCE_ID
     */
	
	private Long resourceId;
    /**
     * userInfoId       db_column: USER_INFO_ID
     */
	
	private Long userInfoId;
    /**
     * resourceName       db_column: RESOURCE_NAME
     */
	@Length(max=200)
	private java.lang.String resourceName;
    /**
     * resourceType       db_column: RESOURCE_TYPE
     */
	
	private Long resourceType;
    /**
     * resourceSize       db_column: RESOURCE_SIZE
     */
	@Length(max=200)
	private java.lang.String resourceSize;
    /**
     * resourceFile       db_column: RESOURCE_FILE
     */
	@Length(max=200)
	private java.lang.String resourceFile;
    /**
     * resourceIssueDate       db_column: RESOURCE_ISSUE_DATE
     */
	
	private java.util.Date resourceIssueDate;
	//columns END


	public Resource(){
	}

	public Resource(
		Long resourceId
	){
		this.resourceId = resourceId;
	}



	public void setResourceId(Long value) {
		this.resourceId = value;
	}

	@Id	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="BJ12320_RESOURCE_SEQU")
    @SequenceGenerator(name="BJ12320_RESOURCE_SEQU",allocationSize=1,initialValue=1, sequenceName="BJ12320_RESOURCE_SEQU")
	@Column(name = "RESOURCE_ID", unique = true, nullable = false, insertable = true, updatable = true, length = 0)
	public Long getResourceId() {
		return this.resourceId;
	}

	@Column(name = "USER_INFO_ID", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public Long getUserInfoId() {
		return this.userInfoId;
	}

	public void setUserInfoId(Long value) {
		this.userInfoId = value;
	}

	@Column(name = "RESOURCE_NAME", unique = false, nullable = true, insertable = true, updatable = true, length = 200)
	public java.lang.String getResourceName() {
		return this.resourceName;
	}

	public void setResourceName(java.lang.String value) {
		this.resourceName = value;
	}

	@Column(name = "RESOURCE_TYPE", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public Long getResourceType() {
		return this.resourceType;
	}

	public void setResourceType(Long value) {
		this.resourceType = value;
	}

	@Column(name = "RESOURCE_SIZE", unique = false, nullable = true, insertable = true, updatable = true, length = 200)
	public java.lang.String getResourceSize() {
		return this.resourceSize;
	}

	public void setResourceSize(java.lang.String value) {
		this.resourceSize = value;
	}

	@Column(name = "RESOURCE_FILE", unique = false, nullable = true, insertable = true, updatable = true, length = 200)
	public java.lang.String getResourceFile() {
		return this.resourceFile;
	}

	public void setResourceFile(java.lang.String value) {
		this.resourceFile = value;
	}

	@Transient
	public String getResourceIssueDateString() {
		return DateConvertUtils.format(getResourceIssueDate(), FORMAT_RESOURCE_ISSUE_DATE);
	}
	public void setResourceIssueDateString(String value) {
		setResourceIssueDate(DateConvertUtils.parse(value, FORMAT_RESOURCE_ISSUE_DATE,java.util.Date.class));
	}

	@Column(name = "RESOURCE_ISSUE_DATE", unique = false, nullable = true, insertable = true, updatable = true, length = 7)
	public java.util.Date getResourceIssueDate() {
		return this.resourceIssueDate;
	}

	public void setResourceIssueDate(java.util.Date value) {
		this.resourceIssueDate = value;
	}


	private UserInfo userInfo;
	public void setUserInfo(UserInfo userInfo){
		this.userInfo = userInfo;
	}

	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "USER_INFO_ID",nullable = false, insertable = false, updatable = false) 
	})
	public UserInfo getUserInfo() {
		return userInfo;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("ResourceId",getResourceId())
			.append("UserInfoId",getUserInfoId())
			.append("ResourceName",getResourceName())
			.append("ResourceType",getResourceType())
			.append("ResourceSize",getResourceSize())
			.append("ResourceFile",getResourceFile())
			.append("ResourceIssueDate",getResourceIssueDate())
			.toString();
	}

	public int hashCode() {
		return new HashCodeBuilder()
			.append(getResourceId())
			.toHashCode();
	}

	public boolean equals(Object obj) {
		if(obj instanceof Resource == false) return false;
		if(this == obj) return true;
		Resource other = (Resource)obj;
		return new EqualsBuilder()
			.append(getResourceId(),other.getResourceId())
			.isEquals();
	}
}

